package com.example.demoweb.controller;

import com.example.demoweb.bean.Person;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.Cookie;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * @Date 2021/6/20 11:37
 * @Created by wangle
 * @Description
 */
@RestController
public class mycontroller {

        //数据绑定，直接和数据属性进行绑定
    @PostMapping("/saveuser")
    public Person saveUser( Person person){
        return person;

    }

  @GetMapping("/car/{id}/owner/{username}")
    public Map<String, Object>  getcar(@PathVariable("id") Integer id, @PathVariable("username") String name,
                                       @PathVariable Map<String,String> pv,
                                       @RequestHeader("User-Agent")String useragent,
                                       @RequestHeader Map<String,Object> headrs,
                                       @RequestParam("age") int age,
                                       @RequestParam("interets")List<String> interets,
                                       @RequestParam Map<String,String> info,
                                       @CookieValue("Idea-81a01b94") Cookie cookie)
  {

     Map<String, Object>  map=new HashMap<>();
//      map.put("id",id);
//      map.put("name",name);
//      map.put("pv" ,pv);
//      map.put("useragent",useragent);
//      map.put("heders",headrs);
      map.put("age",age);
      map.put("interets",interets);
      map.put("info",info);
    map.put("cookie",cookie);
        return map;
    }

    @PostMapping("/save")
    public  Map<String ,Object> postmethon(@RequestBody String content,
                                           @RequestParam("name")String name )
    {
        Map<String ,Object> map=new HashMap<>();
//        map.put("content",content);
        map.put("name",name);
        return map;


    }
}
